package com.sans.structure;

import org.junit.Test;

import java.util.Random;

/**
 * @author Sans
 */
public class ChooseTest {
    @Test
    public void ifStructure() {
        int score = new Random().nextInt(101);
        System.out.println("分数" + score);
        if (score >= 60) {
            System.out.println("你及格了");
        }

        if (score >= 60) {
            System.out.println("你及格了");
        } else {
            System.out.println("你没及格");
        }

        if (score >= 80) {
            System.out.println("你很优秀");
        } else if (score >= 60) {
            System.out.println("你及格了");
        } else if (score >= 0) {
            System.out.println("你没及格");
        } else {
            System.out.println("分数异常");
        }
    }
    @Test
    public void switchStructure(){
        int num = new Random().nextInt(5);
        System.out.println("num:" + num);
        switch (num + 1){
            case 1:
                System.out.println("你的数字是0");
                break;
            case 2:
                System.out.println("你的数字是1");
                break;
            case 3:
                System.out.println("你的数字是2");
                break;
            case 4:
                System.out.println("你的数字是3");
                break;
            case 5:
                System.out.println("你的数字是4");
                break;
            default:
                System.out.println("数字有问题");
                break;
        }
    }
}
